﻿using Lsk.Business.DTO;
using Lsk.Data;
using System;
using System.Collections.Generic;
using System.Data.Entity.Core.Objects;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lsk.Business
{
    public class PropertyDirectory
    {
        private lskEntities _entity;

        public PropertyDirectory()
        {
            _entity = new lskEntities();
        }


        public IEnumerable<GetPropertyDirectory_Result> GetPropertyDirectory()
        {
            ObjectResult<GetPropertyDirectory_Result> propertyDir = _entity.GetPropertyDirectory(0);
            return propertyDir.AsEnumerable<GetPropertyDirectory_Result>();
        }

        public PropertyDirectoryMessage GetPropertyDirectory(string guid)
        {
            PropertyDirectoryMessage response = new PropertyDirectoryMessage();
            GetPropertyDirectory_Result data = (from a in _entity.GetPropertyDirectory(0) where a.ProjectId == new Guid(guid) select a).FirstOrDefault();
            response.project = data;
            
            response.pictureList = _entity.GetPictureByID(guid);
            return response;

        }
    }
}
